home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Add-Ons / XCMDs / OptKeyDown XFCN 1.0.1 / OptKeyDown.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-15  |  1.7 KB  |  74 lines  |  [TEXT/CWIE]

  1. /* ----------------------------------------------------------------------
  2.  
  3.     OptionKeyDown XFCN
  4.     version 1.0.1
  5.     
  6.     Written by: Paul Celestin
  7.     
  8.     Copyright © 1993-1995 Celestin Company, Inc.
  9.     
  10.     This XFCN returns true if the option key is down.
  11.     
  12.     No parameters required!
  13.     
  14.     930927 - 1.0.0 - initial release
  15.     951215 - 1.0.1 - updated for CW7
  16.  
  17. ---------------------------------------------------------------------- */
  18.  
  19. #include <A4Stuff.h>
  20. #include <HyperXCmd.h>
  21.  
  22. #define PARAMETER_NUMS        0
  23. #define PARAMETER_TEXT        "\pNo parameters required!"
  24.  
  25.  
  26. /* ----------------------------------------------------------------------
  27. prototypes
  28. ---------------------------------------------------------------------- */
  29. void DoIt(XCmdPtr paramPtr);
  30. Boolean BitTest(Ptr p, int n);
  31.  
  32.  
  33. /* ----------------------------------------------------------------------
  34. main
  35. ---------------------------------------------------------------------- */
  36. pascal void main(XCmdPtr paramPtr)
  37. {
  38.     long oldA4 = SetCurrentA4();
  39.     if (paramPtr->paramCount != PARAMETER_NUMS)
  40.     {
  41.         paramPtr->returnValue =
  42.             PasToZero(paramPtr,PARAMETER_TEXT);
  43.     }
  44.     else
  45.     {
  46.         DoIt( paramPtr );
  47.     }
  48.     SetA4(oldA4);
  49. }
  50.  
  51. /* ----------------------------------------------------------------------
  52. DoIt
  53. ---------------------------------------------------------------------- */
  54. void DoIt(XCmdPtr paramPtr)
  55. {
  56.     KeyMap        myKeys;
  57.  
  58.     GetKeys(myKeys);
  59.     if (BitTest((Ptr)myKeys, 0x3a)) /* 0x3a is the option key */
  60.         paramPtr->returnValue = PasToZero(paramPtr,"\ptrue");
  61.     else
  62.         paramPtr->returnValue = PasToZero(paramPtr,"\pfalse");
  63.  
  64. }
  65.  
  66.  
  67. /* ----------------------------------------------------------------------
  68. BitTest
  69. ---------------------------------------------------------------------- */
  70. Boolean BitTest(Ptr p, int n)
  71. {
  72.     return(!!(p[n/8] & 1L<<(n%8)));
  73. }
  74.